<?php
$tabs = array(  "index.php",                        "Accueil",
                "articlesList.php?type=news",       "News",
                "articlesList.php?type=test",       "Tests"
             );
$i = 0;
?>

<nav class="navbar navbar-inverse navbar-fixed-top">
	<div class="container">
		<div class="navbar-header">
			<a class="navbar-brand logo" href="<?= WEBROOT ?>index.php">Game's Com</a>
		</div>
		<div id="navbar" class="navbar-collapse collapse">
			<ul class="nav navbar-nav">
			<?php while (isset($tabs[$i])) { ?>
					<li <?php activeUrl($tabs[$i]) ?> >
						<a href="<?= WEBROOT.$tabs[$i] ?>"><?= $tabs[$i+1] ?></a>
					</li>
					<?php
					$i += 2;
				} ?>
			</ul>
			<div class="navbar-form navbar-right">
				<?php if(isset($_SESSION["user_id"])) {
						if($user["roleID"] >= 2) { ?>
							<div class="btn-group">
								<button onclick="document.location.href='<?= WEBROOT ?>moderation/moderation.php'" type="button" class="btn btn-warning btn-margin">Modération</button>
								<button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
									<span class="caret"></span>
									<span class="sr-only">Toggle Dropdown</span>
								</button>
								<ul class="dropdown-menu" role="menu">
									<li><a href="<?= WEBROOT ?>moderation/moderation.php?page=waitingArticles">Articles en attente</a></li>
									<li class="divider"></li>
									<li><a href="<?= WEBROOT ?>moderation/moderation.php?page=allUsers">Tout les utilisateurs</a></li>
									<li><a href="<?= WEBROOT ?>moderation/moderation.php?page=allArticles">Tout les articles</a></li>
									<li><a href="<?= WEBROOT ?>moderation/moderation.php?page=allComments">Tout les commentaires</a></li>
									<li><a href="<?= WEBROOT ?>moderation/moderation.php?page=allPictures">Toutes les images</a></li>
								</ul>
							</div>
						<?php } ?>
					<div class="btn-group">
						<button onclick="document.location.href='<?= WEBROOT ?>compte/compte.php'" type="button" class="btn btn-primary btn-margin"><?= $user["firstName"]."&nbsp;".$user["lastName"] ?></button>
						<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
							<span class="caret"></span>
							<span class="sr-only">Toggle Dropdown</span>
						</button>
						<ul class="dropdown-menu" role="menu">
							<li><a href="<?= WEBROOT ?>compte/compte.php?page=information">Mes Informations</a></li>
							<li class="divider"></li>
							<li><a href="<?= WEBROOT ?>compte/compte.php?page=historique">Mon Historique</a></li>
							<li><a href="<?= WEBROOT ?>compte/compte.php?page=myArticles">Mes Articles</a></li>
							<li><a href="<?= WEBROOT ?>compte/compte.php?page=myComments">Mes Commentaires</a></li>
							<li><a href="<?= WEBROOT ?>compte/compte.php?page=myNotes">Mes Notes</a></li>
							<li class="divider"></li>
							<li><a href="<?= WEBROOT ?>compte/compte.php?page=createArticle">Proposer son article</a></li>
						</ul>
					</div>

					<form action="<?= WEBROOT ?>connexion.php" method="post" class="inline-form">
						<button type="submit" name="disconnect" class="btn btn-danger">Se déconnecter</button>
					</form>
				<?php }else { ?>
					<a href="<?= WEBROOT ?>connexion.php?redirect=true" class="btn btn-success">Se connecter</a>
					<a href="<?= WEBROOT ?>inscription.php" class="btn btn-default">S'inscrire</a>
				<?php } ?>
			</div>
		</div>
	</div>
</nav>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="<?= WEBROOT ?>js/bootstrap.min.js"></script>

